home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / prog_d / isamexpt.zip / WNTISAM2.PAS < prev    next >
Pascal/Delphi Source File  |  1996-01-13  |  18KB  |  539 lines

  1. unit Wntisam2;
  2.  
  3. interface
  4.  
  5. uses WinTypes, Classes, Graphics, Forms;
  6.  
  7. function Erzeuge_EditorForm(const FormIdent: string;
  8.                             RecList: TStringList;
  9.                             Label_Neben_Input: Boolean;
  10.                             InputLen_Fest: Boolean;
  11.                             LFont, EFont: TFont;
  12.                             Sprache: Integer): TForm;
  13.  
  14. implementation
  15.  
  16. Uses WinProcs, SysUtils, Controls, ExtCtrls, Proxies,
  17.      Db, WntIsam4, StdCtrls, Buttons, IsamTabl;
  18.  
  19. function Erzeuge_EditorForm(const FormIdent: string;
  20.                             RecList: TStringList;
  21.                             Label_Neben_Input: Boolean;
  22.                             InputLen_Fest: Boolean;
  23.                             LFont, EFont: TFont;
  24.                             Sprache: Integer): TForm;
  25. var
  26.   BtnPos   : TPoint;
  27.   Method,KeyMethod: TMethod;
  28.   MP,UP,UP1,UP2,UP3: TPanel;
  29.   SP       : TSpeedButton;
  30.   Tbl      : TIsamTable;
  31.   W,i,Ty,G : Integer;
  32.   SLab     : TLabel;
  33.   {$IFDEF SHAREWARE}
  34.   SInp     : TOvcSimpleField;
  35.   PInp     : TOvcPictureField;
  36.   NInp     : TOvcNumericField;
  37.   {$ELSE}
  38.   SInp     : TEdit;
  39.   PInp     : TEdit;
  40.   NInp     : TEdit;
  41.   {$ENDIF}
  42.   MInp     : TMemo;
  43.   Tm       : TTimer;
  44.   FieldName,FeldName,SStr,AStr: String;
  45.   Len,Arr1,Arr2,A    : Integer;
  46.   FieldDataType      : TFieldType;
  47. begin
  48.   Result := TProxyForm.CreateAs('T' + FormIdent);
  49.   with Result do begin
  50.     BorderStyle := bsDialog;
  51.     Left:= 100;
  52.     Top:= 101;
  53.     Width := 400;
  54.     Height := 282;
  55.     Position := poScreenCenter;
  56.     Name := FormIdent;
  57.     Caption := FormIdent;
  58.     KeyPreview:= True;
  59.     AutoScroll  := True;
  60.     Method.Code := TProxyForm(Result).CreateMethod('FormCreate');
  61.     Method.Data := Result;
  62.     OnCreate    := TNotifyEvent(Method);
  63.     KeyMethod.Code:= TProxyForm(Result).CreateMethod('FormKeyPress');
  64.     KeyMethod.Data:= Result;
  65.     OnKeyPress:= TKeyPressEvent(KeyMethod);
  66.     with Font do begin
  67.       Color := clBlack;
  68.       Height:= -11;
  69.       Name := 'Arial';
  70.       Size := 8;
  71.       Style:= [fsBold];
  72.     end;
  73.  
  74.     {$IFDEF SHAREWARE}
  75.     With TOvcController.Create(Result) do begin
  76.       Name:= 'DefaultController';
  77.     end;
  78.     {$ENDIF}
  79.  
  80.     MP:= TPanel.Create(Result);
  81.     with MP do begin
  82.       Parent := Result;
  83.       Name := 'Panel1';
  84.       Align := alTop;
  85.       ShowHint:= True;
  86.       Caption:= '';
  87.     end;
  88.  
  89.     Sp:= TSpeedButton.Create(Result);
  90.     with SP do begin
  91.       Parent:= MP;
  92.       Left:= 10;
  93.       Top := 8;
  94.       Width := 25;
  95.       Height := 25;
  96.       if Sprache = 1 then Hint:= 'Back'
  97.       else Hint := 'Zurⁿck';
  98.       Name := 'RueckBttn';
  99.       Glyph.Handle:= LoadBitmap(HInstance,'IS_RUECK');
  100.       Method.Code := TProxyForm(Result).CreateMethod('RueckBttnClick');
  101.       Method.Data := Result;
  102.       Sp.OnClick := TNotifyEvent(Method);
  103.     end;
  104.  
  105.     Sp:= TSpeedButton.Create(Result);
  106.     with SP do begin
  107.       Parent:= MP;
  108.       Left:= 35;
  109.       Top := 8;
  110.       Width := 25;
  111.       Height := 25;
  112.       if Sprache = 1 then Hint:= 'forward'
  113.       else Hint := 'VorwΣrts';
  114.       Name := 'VorBttn';
  115.       Glyph.Handle:= LoadBitmap(HInstance,'IS_VOR');
  116.       Method.Code := TProxyForm(Result).CreateMethod('VorBttnClick');
  117.       Method.Data := Result;
  118.       Sp.OnClick := TNotifyEvent(Method);
  119.     end;
  120.  
  121.     Sp:= TSpeedButton.Create(Result);
  122.     with SP do begin
  123.       Parent:= MP;
  124.       Left:= 60;
  125.       Top := 8;
  126.       Width := 25;
  127.       Height := 25;
  128.       if Sprache = 1 then Hint:= 'Search'
  129.       else Hint := 'Suchen';
  130.       Name := 'SuchBttn';
  131.       Glyph.Handle:= LoadBitmap(HInstance,'IS_SUCH');
  132.       Method.Code := TProxyForm(Result).CreateMethod('SuchBttnClick');
  133.       Method.Data := Result;
  134.       Sp.OnClick := TNotifyEvent(Method);
  135.     end;
  136.  
  137.     Sp:= TSpeedButton.Create(Result);
  138.     with SP do begin
  139.       Parent:= MP;
  140.       Left:= 85;
  141.       Top := 8;
  142.       Width := 25;
  143.       Height := 25;
  144.       if Sprache = 1 then Hint:= 'Sort order'
  145.       else Hint := 'Sortierordnung';
  146.       Name := 'KeyBttn';
  147.       Glyph.Handle:= LoadBitmap(HInstance,'IS_KEY');
  148.       Method.Code := TProxyForm(Result).CreateMethod('KeyBttnClick');
  149.       Method.Data := Result;
  150.       Sp.OnClick := TNotifyEvent(Method);
  151.     end;
  152.  
  153.     Sp:= TSpeedButton.Create(Result);
  154.     with SP do begin
  155.       Parent:= MP;
  156.       Left:= 110;
  157.       Top := 8;
  158.       Width := 25;
  159.       Height := 25;
  160.       if Sprache = 1 then Hint:= 'clear'
  161.       else Hint := 'Leeren';
  162.       Name := 'NeuBttn';
  163.       Glyph.Handle:= LoadBitmap(HInstance,'IS_NEU');
  164.       Method.Code := TProxyForm(Result).CreateMethod('NeuBttnClick');
  165.       Method.Data := Result;
  166.       Sp.OnClick := TNotifyEvent(Method);
  167.     end;
  168.  
  169.     Sp:= TSpeedButton.Create(Result);
  170.     with SP do begin
  171.       Parent:= MP;
  172.       Left:= 135;
  173.       Top := 8;
  174.       Width := 25;
  175.       Height := 25;
  176.       if Sprache = 1 then Hint:= 'save new record'
  177.       else Hint := 'Anlegen';
  178.       Name := 'AnlegBttn';
  179.       Glyph.Handle:= LoadBitmap(HInstance,'IS_ANLEGEN');
  180.       Method.Code := TProxyForm(Result).CreateMethod('AnlegBttnClick');
  181.       Method.Data := Result;
  182.       Sp.OnClick := TNotifyEvent(Method);
  183.     end;
  184.  
  185.     Sp:= TSpeedButton.Create(Result);
  186.     with SP do begin
  187.       Parent:= MP;
  188.       Left:= 160;
  189.       Top := 8;
  190.       Width := 25;
  191.       Height := 25;
  192.       if Sprache = 1 then Hint:= 'save changed record'
  193.       else Hint := '─ndern';
  194.       Name := 'AendernBttn';
  195.       Glyph.Handle:= LoadBitmap(HInstance,'IS_AENDERN');
  196.       Method.Code := TProxyForm(Result).CreateMethod('AendernBttnClick');
  197.       Method.Data := Result;
  198.       Sp.OnClick := TNotifyEvent(Method);
  199.     end;
  200.  
  201.     Sp:= TSpeedButton.Create(Result);
  202.     with SP do begin
  203.       Parent:= MP;
  204.       Left:= 185;
  205.       Top := 8;
  206.       Width := 25;
  207.       Height := 25;
  208.       if Sprache = 1 then Hint:= 'delete record'
  209.       else Hint := 'L÷schen';
  210.       Name := 'LoeschBttn';
  211.       Glyph.Handle:= LoadBitmap(HInstance,'IS_LOESCHEN');
  212.       Method.Code := TProxyForm(Result).CreateMethod('LoeschBttnClick');
  213.       Method.Data := Result;
  214.       Sp.OnClick := TNotifyEvent(Method);
  215.     end;
  216.  
  217.     Sp:= TSpeedButton.Create(Result);
  218.     with SP do begin
  219.       Parent:= MP;
  220.       Left:= 215;
  221.       Top := 8;
  222.       Width := 25;
  223.       Height := 25;
  224.       Hint := 'Ok';
  225.       Name := 'OkBttn';
  226.       Glyph.Handle:= LoadBitmap(HInstance,'IS_OK');
  227.       Method.Code := TProxyForm(Result).CreateMethod('OkBttnClick');
  228.       Method.Data := Result;
  229.       Sp.OnClick := TNotifyEvent(Method);
  230.     end;
  231.  
  232.     Sp:= TSpeedButton.Create(Result);
  233.     with SP do begin
  234.       Parent:= MP;
  235.       Left:= 358;
  236.       Top := 8;
  237.       Width := 25;
  238.       Height := 25;
  239.       if Sprache = 1 then Hint:= 'End'
  240.       else Hint := 'Ende';
  241.       Name := 'AbbruchBttn';
  242.       Glyph.Handle:= LoadBitmap(HInstance,'IS_ENDE');
  243.       Method.Code := TProxyForm(Result).CreateMethod('AbbruchBttnClick');
  244.       Method.Data := Result;
  245.       Sp.OnClick := TNotifyEvent(Method);
  246.     end;
  247.  
  248.     UP:= TPanel.Create(Result);
  249.     with UP do begin
  250.       Parent := Result;
  251.       Name := 'Panel2';
  252.       Align := alBottom;
  253.       BevelInner:= bvLowered;
  254.       Height:= 27;
  255.       ShowHint:= False;
  256.       Caption:= '';
  257.     end;
  258.  
  259.     UP1:= TPanel.Create(Result);
  260.     With UP1 do begin
  261.       Parent:= UP;
  262.       Left  := 308;
  263.       Top   := 2;
  264.       Width := 108;
  265.       Height:= 23;
  266.       Align := alRight;
  267.       BevelOuter := bvLowered;
  268.       Font.Color := clBlack;
  269.       Font.Height := -11;
  270.       Font.Name := 'Arial';
  271.       Font.Style := [];
  272.       Name:= 'ZeitPanel';
  273.       Caption:= '';
  274.     end;
  275.  
  276.     UP3:= TPanel.Create(Result);
  277.     with UP3 do begin
  278.       Parent:= UP;
  279.       Left  := 2;
  280.       Top   := 2;
  281.       Width := 186;
  282.       Height:= 23;
  283.       Align := alClient;
  284.       ShowHint:= True;
  285.       BevelInner := bvLowered;
  286.       BevelOuter := bvNone;
  287.       Font.Color := clBlack;
  288.       Font.Height := -11;
  289.       Font.Name   := 'Arial';
  290.       Font.Style  := [];
  291.       Name:= 'HintPanel';
  292.       Caption:= '';
  293.     end;
  294.  
  295.     Tm:= TTimer.Create(Result);
  296.     With Tm do begin
  297.       Interval:= 1000;
  298.       Name:= FormIdent+'Timer';
  299.       Method.Code := TProxyForm(Result).CreateMethod(FormIdent+'TimerTimer');
  300.       Method.Data := Result;
  301.       Tm.OnTimer := TNotifyEvent(Method);
  302.     end;
  303.  
  304.     Tbl:= TIsamTable.Create(Result);
  305.     with Tbl do begin
  306.       Name:= FormIdent+'TABLE';
  307.       TableName   := '';
  308.     end;
  309.  
  310.     if RecList.Count > 0 then begin
  311.       Ty:= 52;
  312.       For i:= 0 to RecList.Count - 1 do begin
  313.         SStr:= RecList[i];
  314.         if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0)
  315.         and (Pos('IGNORE',Uppercase(SStr)) = 0) then begin
  316.           G:= GetFieldTypEditor(SStr,FeldName,FieldDataType,Len,Arr1,Arr2);
  317.           FieldName:= FeldName;
  318.           if Label_Neben_Input = False then Inc(Ty,18);
  319.           if InputLen_Fest then W:= 130 else W:= 8 * (Len - 1);
  320.           if W < 30 then W:= 30;
  321.           For a:= Arr1 to Arr2 do begin
  322.             if Arr1 <> Arr2 then begin
  323.               Str(A,AStr);
  324.               FieldName:= FeldName+AStr;
  325.             end;
  326.             {$IFDEF SHAREWARE}
  327.             Case G of
  328.               1: begin
  329.                    PInp:= TOvcPictureField.Create(Result);
  330.                    with PInp do begin
  331.                      Name:= FieldName + 'Input';
  332.                      Parent:= Result;
  333.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  334.                      Top   := Ty;
  335.                      Width := W;
  336.                      Height := 21;
  337.                      Cursor := crIBeam;
  338.                      HighlightColors.BackColor := clHighlight;
  339.                      HighlightColors.TextColor := clHighlightText;
  340.                      HighlightColors.UseDefault := False;
  341.                      Font.Color := EFont.Color;
  342.                      Font.Height := EFont.Height;
  343.                      Font.Name := EFont.Name;
  344.                      Font.Style := EFont.Style;
  345.                      ParentColor := False;
  346.                      TabStop := True;
  347.                      if FieldDataType = ftTime then begin
  348.                        DataType := pftTime;
  349.                        MaxLength:= 5;
  350.                        PictureMask:= 'hh:mm';
  351.                        RangeHi:= '23:59';
  352.                        RangeLo:= '00:00';
  353.                      end
  354.                      else begin
  355.                        DataType:= pftDate;
  356.                        MaxLength:= 10;
  357.                        PictureMask := 'dd/mm/yyyy';
  358.                      end;
  359.                    end;
  360.                  end;
  361.               2: begin
  362.                    SInp:= TOvcSimpleField.Create(Result);
  363.                    with SInp do begin
  364.                      Name:= FieldName + 'Input';
  365.                      Parent:= Result;
  366.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  367.                      Top   := Ty;
  368.                      Width := W;
  369.                      Height := 21;
  370.                      Cursor := crIBeam;
  371.                      HighlightColors.BackColor := clHighlight;
  372.                      HighlightColors.TextColor := clHighlightText;
  373.                      HighlightColors.UseDefault := False;
  374.                      Font.Color := EFont.Color;
  375.                      Font.Height := EFont.Height;
  376.                      Font.Name := EFont.Name;
  377.                      Font.Style := EFont.Style;
  378.                      ParentColor := False;
  379.                      TabStop := True;
  380.                      Case FieldDataType of
  381.                        ftInteger : DataType:= sftLongint;
  382.                        ftSmallInt: DataType:= sftShortInt;
  383.                        ftWord    : DataType:= sftWord;
  384.                        else begin
  385.                          DataType:= sftReal;
  386.                          DecimalPlaces:= 2;
  387.                        end;
  388.                      end;
  389.                    end;
  390.                  end;
  391.               3: begin
  392.                    MInp:= TMemo.Create(Result);
  393.                    with MInp do begin
  394.                      Name:= FieldName + 'Input';
  395.                      Parent:= Result;
  396.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  397.                      Top   := Ty;
  398.                      Width := 130;
  399.                      Height := 89;
  400.                      Font.Color := EFont.Color;
  401.                      Font.Height := EFont.Height;
  402.                      Font.Name := Efont.Name;
  403.                      Font.Style := EFont.Style;
  404.                      ParentColor := False;
  405.                      TabStop := True;
  406.                    end;
  407.                  end;
  408.               else begin
  409.                    SInp:= TOvcSimpleField.Create(Result);
  410.                    with SInp do begin
  411.                      Name:= FieldName + 'Input';
  412.                      Parent:= Result;
  413.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  414.                      Top   := Ty;
  415.                      Width := W;
  416.                      Height := 21;
  417.                      Cursor := crIBeam;
  418.                      HighlightColors.BackColor := clHighlight;
  419.                      HighlightColors.TextColor := clHighlightText;
  420.                      HighlightColors.UseDefault := False;
  421.                      Font.Color := EFont.Color;
  422.                      Font.Height := EFont.Height;
  423.                      Font.Name := EFont.Name;
  424.                      Font.Style := EFont.Style;
  425.                      ParentColor := False;
  426.                      TabStop := True;
  427.                      DataType := sftString;
  428.                      MaxLength := Len;
  429.                      PictureMask := 'X';
  430.                    end;
  431.                  end;
  432.             end;
  433.             {$ELSE}
  434.             Case G of
  435.               1: begin
  436.                    PInp:= TEdit.Create(Result);
  437.                    with PInp do begin
  438.                      Name:= FieldName + 'Input';
  439.                      Parent:= Result;
  440.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  441.                      Top   := Ty;
  442.                      Width := W;
  443.                      Height := 21;
  444.                      Cursor := crIBeam;
  445.                      Font.Color := EFont.Color;
  446.                      Font.Height := EFont.Height;
  447.                      Font.Name := EFont.Name;
  448.                      Font.Style := EFont.Style;
  449.                      ParentColor := False;
  450.                      TabStop := True;
  451.                      if FieldDataType = ftTime then begin
  452.                        MaxLength:= 5;
  453.                      end
  454.                      else begin
  455.                        MaxLength:= 10;
  456.                      end;
  457.                    end;
  458.                  end;
  459.               2: begin
  460.                    SInp:= TEdit.Create(Result);
  461.                    with SInp do begin
  462.                      Name:= FieldName + 'Input';
  463.                      Parent:= Result;
  464.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  465.                      Top   := Ty;
  466.                      Width := W;
  467.                      Height := 21;
  468.                      Cursor := crIBeam;
  469.                      Font.Color := EFont.Color;
  470.                      Font.Height := EFont.Height;
  471.                      Font.Name := EFont.Name;
  472.                      Font.Style := EFont.Style;
  473.                      ParentColor := False;
  474.                      TabStop := True;
  475.                    end;
  476.                  end;
  477.               3: begin
  478.                    MInp:= TMemo.Create(Result);
  479.                    with MInp do begin
  480.                      Name:= FieldName + 'Input';
  481.                      Parent:= Result;
  482.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  483.                      Top   := Ty;
  484.                      Width := 130;
  485.                      Height := 89;
  486.                      Font.Color := EFont.Color;
  487.                      Font.Height := EFont.Height;
  488.                      Font.Name := Efont.Name;
  489.                      Font.Style := EFont.Style;
  490.                      ParentColor := False;
  491.                      TabStop := True;
  492.                    end;
  493.                  end;
  494.               else begin
  495.                    SInp:= TEdit.Create(Result);
  496.                    with SInp do begin
  497.                      Name:= FieldName + 'Input';
  498.                      Parent:= Result;
  499.                      if Label_Neben_Input then Left:= 100 else Left:= 20;
  500.                      Top   := Ty;
  501.                      Width := W;
  502.                      Height := 21;
  503.                      Cursor := crIBeam;
  504.                      Font.Color := EFont.Color;
  505.                      Font.Height := EFont.Height;
  506.                      Font.Name := EFont.Name;
  507.                      Font.Style := EFont.Style;
  508.                      ParentColor := False;
  509.                      TabStop := True;
  510.                      MaxLength:= Len;
  511.                    end;
  512.                  end;
  513.              end;
  514.             {$ENDIF}
  515.             if Label_Neben_Input = False then Dec(Ty,18);
  516.             SLab:= TLabel.Create(Result);
  517.             With SLab do begin
  518.               Name:= FieldName+'Label';
  519.               Parent:= Result;
  520.               Caption:= FieldName;
  521.               Left:= 20;
  522.               Top:= Ty + 2;
  523.               Font.Color := LFont.Color;
  524.               Font.Height := LFont.Height;
  525.               Font.Name := LFont.Name;
  526.               Font.Style := LFont.Style;
  527.             end;
  528.             Ty:= Ty+24;
  529.             if Label_Neben_Input = False then Inc(Ty,20);
  530.             if G = 3 then Ty:= Ty + 68;
  531.           end; {for arr1 to arr2}
  532.         end;
  533.       end;
  534.     end;
  535.   end;
  536. end;
  537.  
  538. end.
  539.